# -*- coding: utf-8 -*-
import logging
import py_global

logger = logging.getLogger(__name__)


def fibonacci():
    f0 = f1 = 1
    yield f0
    yield f1
    while True:
        f0, f1 = f1, f0 + f1
        yield f1


def test_fibonacci():
    for i in fibonacci():
        if i > 100:
            break
        print(i)
        pass

    pass


def generator_name():
    a = ''
    yield a


def fibonacci():
    f0 = f1 = 1
    yield f0
    yield f1
    while True:
        f0, f1 = f1, f0 + f1
        yield f1
    pass


def gen_name(param):
    print(f'before:{param}')
    result = yield param
    print(f'after:{result}')
    yield result


def test_generator():
    gen = gen_name('before')
    result = gen.send(None)
    print(f'send:{result}')
    result = gen.send('after')
    print(f'send:{result}')

    # gen.throw()
    gen.close()


if __name__ == '__main__':


    test_fibonacci()
    test_generator()

    pass
